package com.aaa.controller;

import com.aaa.common.domain.RentInContractCRUDInfo;
import com.aaa.common.domain.RentInContractInfo;
import com.aaa.common.query.PageQuery;
import com.aaa.common.query.ReminderContractConditionalQuery;
import com.aaa.common.query.RentInContractQuery;
import com.aaa.common.result.Result;
import com.aaa.service.impl.ContractReminderServiceImpl;
import com.aaa.service.impl.RentInContractCRUDServiceImpl;
import com.aaa.service.impl.RentInContractServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: 宋文森
 * @Date: 2021/02/05/15:24
 * @Description: 资产租入合同业务控制器
 */
@RestController
@RequestMapping("/rentInContract")
public class RentInContractInfoController  {

    @Autowired
    private RentInContractServiceImpl rentInContractService;
    @Autowired
    private RentInContractCRUDServiceImpl rentInContractCRUDService;
    @Autowired
    private ContractReminderServiceImpl contractReminderService;//合同到期提醒依赖

    /**
     * 公有资产租入合同查询
     * @param pageQuery
     * @return
     */
    @PostMapping("/listPublicAssets")
    public Result listPublicAssetsRentIn(@RequestBody PageQuery pageQuery){
      return   rentInContractService.listPublicAssetsRentInContract(pageQuery);
    }

    /**
     * 其他资产租入合同查询
     * @param pageQuery
     * @return
     */
    @PostMapping("/listOtherAssets")
    public Result listOtherAssetsRentIn(@RequestBody PageQuery pageQuery){
        return   rentInContractService.listOtherAssetsRentInContract(pageQuery);
    }

    /**
     * 公有资产租入合同的条件查询
     * @param rentInContractQuery
     * @return
     */
    @PostMapping("/publicAssetsConditionalQuery")
    public Result  publicOtherConditionalQuery(@RequestBody RentInContractQuery rentInContractQuery ){
      return   rentInContractService.publicOtherConditionalQuery(rentInContractQuery);
    }

    /**
     * 其他资产租入合同的条件查询
     * @param rentInContractQuery
     * @return
     */
    @PostMapping("/OtherAssetsConditionalQuery")
    public Result  OtherAssetsConditionalQuery(@RequestBody RentInContractQuery rentInContractQuery ){
        return   rentInContractService.OtherAssetsConditionalQuery(rentInContractQuery);
    }

    /**
     * 公有资产租入合同的添加操作
     * @param rentInContractCRUDInfo
     * @return
     */
    @PostMapping("/insertPublicAssetRentInContract")
    public Result insertPublicAssetRentInContract(@RequestBody RentInContractCRUDInfo rentInContractCRUDInfo){
       //当添加公有资产租入合同时  资产类型为公有 资产类型编号：2
        return rentInContractCRUDService.RentInContractAdd(rentInContractCRUDInfo);
    }

    /**
     * 其他资产租入合同的添加操作
     * @param rentInContractCRUDInfo
     * @return
     */
    @PostMapping("/insertOtherAssetRentInContract")
    public Result insertOtherAssetRentInContract(@RequestBody RentInContractCRUDInfo rentInContractCRUDInfo){

        return rentInContractCRUDService.RentInContractAdd(rentInContractCRUDInfo);
    }

    /**
     * 在资产租入合同的添加时输入资产编号查询相应资产的租赁地址
     * @param rentInContractCRUDInfo
     * @return
     */
    @PostMapping("/getAddressByAssetId")
    public Result getAddressByAssetId(@RequestBody RentInContractCRUDInfo rentInContractCRUDInfo){
      return   rentInContractCRUDService.selectAddress(rentInContractCRUDInfo);
    }

    /**
     * 租入合同修改操作前的查询操作
     * @param id
     * @return
     */
    @GetMapping("/listRentInContractById")
    public Result listRentInContractById(int id){
        return rentInContractCRUDService.listRentInContractById(id);
    }

    /**
     * 其他资产租入合同的修改操作
     * @param rentInContractInfo
     * @return
     */
    @PostMapping("/updateOtherAssetRentInContract")
    public Result updateOtherAssetRentInContract(@RequestBody RentInContractInfo rentInContractInfo){
        return rentInContractCRUDService.updateRentInContract(rentInContractInfo);
    }

    /**
     * 公有资产租入合同的修改操作
     * @param rentInContractInfo
     * @return
     */
    @PostMapping("/updatePublicAssetRentInContract")
    public Result updatePublicAssetRentInContract(@RequestBody RentInContractInfo rentInContractInfo){
        return rentInContractCRUDService.updateRentInContract(rentInContractInfo);
    }



    /**
     * 资产租入的删除操作
     * @param id
     * @return
     */
    @GetMapping("/deleteRentInContract")
    public Result deleteRentInContractById(int id){
        return   rentInContractCRUDService.deleteRentInContractById(id);
    }

    /**
     * 租入合同到期提醒相关信息的查询
     * @param pageQuery
     * @return
     */
    @PostMapping("/listRentInContract")
    public Result listRentInContract(@RequestBody PageQuery pageQuery){
        return   contractReminderService.listRentInContract(pageQuery);
    }

    /**
     * 租入合同到期提醒的下拉框查询信息
     * @return
     */
    @GetMapping("/listRentInContract/listLessor")
    public Result listLessor(){
        return contractReminderService.listLessor();
    }

    /**
     * 租入合同到期提醒的条件查询
     * @param reminderContractConditionalQuery
     * @return
     */
    @PostMapping("/listRentInContract/RentInContractConditionalQuery")
    public Result RentInContractConditionalQuery(@RequestBody ReminderContractConditionalQuery reminderContractConditionalQuery){
        return   contractReminderService.RentInContractConditionalQuery(reminderContractConditionalQuery);
    }














}
